var util = require('../../libs/util.js');
//获取应用实例
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    monthly_statement_mode:1,
    price_schedule_show:1,
    day_report_push:1,
    day_report_time:'20:30',
    day_report_date_list:['当天','前一天','前二天'],
    day_report_date_index:0,
    auto_copy_delivery_date_list:['前一天'],
    auto_copy_delivery_date_index:0,
    auto_copy_delivery_time:'06:00',
    system_service_charge:0,
    income_taxes:0,
    auto_copy_project_name:'全部',
    auto_copy_project:'',
    price_driver_show:1,
    delivery_date_before_today:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    this.setData({
      monthly_statement_mode:app.globalData.monthly_statement_mode == 'project'?1:0,
      price_schedule_show: app.globalData.price_schedule_show2?true:false,
      day_report_push: app.globalData.day_report_push,
      day_report_time: app.globalData.day_report_time,
      day_report_date_index: this.data.day_report_date_list.indexOf(app.globalData.day_report_date),
      system_service_charge: app.globalData.system_service_charge,
      payment_mode:app.globalData.payment_mode,
      income_taxes:app.globalData.income_taxes,
      taxrate:app.globalData.taxrate,
      auto_reach:app.globalData.auto_reach,
      auto_copy_delivery:app.globalData.auto_copy_delivery,
      auto_copy_project_name:app.globalData.auto_copy_project_name,
      auto_copy_project:app.globalData.auto_copy_project,
      auto_copy_delivery_date_index: this.data.auto_copy_delivery_date_list.indexOf(app.globalData.auto_copy_delivery_date),
      auto_copy_delivery_time:app.globalData.auto_copy_delivery_time,
      auto_copy_delivery_vehicle:app.globalData.auto_copy_delivery_vehicle,
      isAdmin:app.globalData.coAdmin,
      price_driver_show: app.globalData.price_driver_show?true:false,
      delivery_date_before_today: app.globalData.delivery_date_before_today?true:false
    })
    //角色切换
    util.getRoleList(this, app.globalData.CO_ID, app.globalData.role_default, app.globalData.roleData);
  },
  reLaunch: function () {
    wx.reLaunch({
      url: '/pages/index/index'
    })
  },
  //角色切换
  changeRole: function (e) {
    var role = e.currentTarget.dataset.role;
    var co_id = e.currentTarget.dataset.co_id;
    app.globalData.role_default = role;
    app.globalData.CO_ID = co_id;
    util.putData("/atapi/user/user/changeDefaultRole", {
      role: role,
      user_id: app.globalData.user_id,
      CO_ID: co_id
    }, function (res, error) {
      console.log(res); console.log(error)
      wx.hideLoading();
      if (error) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000
        });
        return false;
      }
      if (res.data.success) {
        wx.showModal({
          title: '温馨提示',
          content: '切换默认角色成功！',
          showCancel:false,
          success: function (res) {
            
            wx.redirectTo({
              url: '/pages/index/index'
            })
          }
        })
      } else if (res.data.success == false) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000,
          mask: true
        });
      }
    });
  },
  //企业切换
  changeCompany: function (e) {
    util.getCompanyList(this, app.globalData.CO_ID, app.globalData.roleData);
    this.setData({
      modalName: 'companyListModal'
    })
  },
  //企业选择
  selectCompany: function (e) {
    var CO_ID = e.currentTarget.dataset.co_id;
    app.globalData.CO_ID = CO_ID;
    this.setData({
      modalName: null
    })
    util.getRoleList(this, app.globalData.CO_ID, '', app.globalData.roleData);
  },
  bindInput: function (e) {
    var item = String(e.currentTarget.id), item_value = {};
    item_value[item] = e.detail.value;
    this.setData(item_value);
  },
  systemServiceCharge:function(){
    var that = this;
    if(isNaN(that.data.system_service_charge) == true || that.data.system_service_charge < 0){
      wx.showToast({
          title: '无效价格',
          image: '/images/wrong.png',
          duration: 3000
        });
        return false;
    }
    util.putData("/atapi/enterprise/enterprise/systemServiceCharge", {
      system_service_charge: that.data.system_service_charge,
      CO_ID: app.globalData.CO_ID
    }, function (res, error) {
      console.log(res); console.log(error)
      wx.hideLoading();
      if (error) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000
        });
        return false;
      }
      if (res.data.success) {
        app.globalData.system_service_charge = that.data.system_service_charge
        wx.showModal({
          title: '温馨提示',
          content: '设置收取车辆系统服务费成功！',
          showCancel:false,
          success: function (res) {

          }
        })
      } else if (res.data.success == false) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000,
          mask: true
        });
      }
    });
  },
  taxrateCharge:function(){
    var that = this;
    if(isNaN(that.data.taxrate) == true || Number(that.data.taxrate) < 0 || Number(that.data.taxrate) > 100){
      wx.showToast({
          title: '无效价格',
          image: '/images/wrong.png',
          duration: 3000
        });
        return false;
    }
    util.putData("/atapi/enterprise/enterprise/taxrateCharge", {
      taxrate: that.data.taxrate,
      CO_ID: app.globalData.CO_ID
    }, function (res, error) {
      console.log(res); console.log(error)
      wx.hideLoading();
      if (error) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000
        });
        return false;
      }
      if (res.data.success) {
        app.globalData.taxrate = Number(that.data.taxrate);
        wx.showModal({
          title: '温馨提示',
          content: '设置收入扣税税率成功！',
          showCancel:false,
          success: function (res) {

          }
        })
      } else if (res.data.success == false) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000,
          mask: true
        });
      }
    });
  },
  dayReportDateChange(e) {
    var that = this;
     this.setData({
      day_report_date_index: e.detail.value
    })
    console.log(e.detail.value)
    console.log(that.data.day_report_date_list)
    util.putData("/atapi/enterprise/enterprise/dayReportDate", {
      day_report_date: that.data.day_report_date_list[e.detail.value],
      day_report_push: app.globalData.day_report_push?1:0,
      CO_ID: app.globalData.CO_ID,
      CO_NAME: app.globalData.CO_NAME
    }, function (res, error) {
      console.log(res); console.log(error)
      wx.hideLoading();
      if (error) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000
        });
        return false;
      }
      if (res.data.success) {
        app.globalData.day_report_date  = that.data.day_report_date_list[e.detail.value]
        wx.showModal({
          title: '温馨提示',
          content: '设置日报推送日期成功！',
          showCancel:false,
          success: function (res) {

          }
        })
      } else if (res.data.success == false) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000,
          mask: true
        });
      }
    });
  },
  autoCopyDeliveryDate(e) {
    var that = this;
     this.setData({
      auto_copy_delivery_date_index: e.detail.value
    })
    console.log(e.detail.value)
    console.log(that.data.auto_copy_delivery_date_list)
    util.putData("/atapi/enterprise/enterprise/autoCopyDeliveryDate", {
      auto_copy_delivery_date: that.data.auto_copy_delivery_date_list[e.detail.value],
      CO_ID: app.globalData.CO_ID,
      CO_NAME: app.globalData.CO_NAME
    }, function (res, error) {
      console.log(res); console.log(error)
      wx.hideLoading();
      if (error) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000
        });
        return false;
      }
      if (res.data.success) {
        app.globalData.auto_copy_delivery_date  = that.data.auto_copy_delivery_date_list[e.detail.value]
        wx.showModal({
          title: '温馨提示',
          content: '设置自动复制运单日期成功！',
          showCancel:false,
          success: function (res) {

          }
        })
      } else if (res.data.success == false) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000,
          mask: true
        });
      }
    });
  },
  TimeChange(e) {
    this.setData({
      day_report_time: e.detail.value
    })
    util.putData("/atapi/enterprise/enterprise/dayReportTime", {
      day_report_time: e.detail.value,
      day_report_push: app.globalData.day_report_push?1:0,
      CO_ID: app.globalData.CO_ID,
      CO_NAME: app.globalData.CO_NAME
    }, function (res, error) {
      console.log(res); console.log(error)
      wx.hideLoading();
      if (error) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000
        });
        return false;
      }
      if (res.data.success) {
        app.globalData.day_report_time = e.detail.value
        wx.showModal({
          title: '温馨提示',
          content: '设置日报推送时间成功！',
          showCancel:false,
          success: function (res) {

          }
        })
      } else if (res.data.success == false) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000,
          mask: true
        });
      }
    });
  },
  autoCopyDeliveryTimeChange(e) {
    this.setData({
      auto_copy_delivery_time: e.detail.value
    })
    util.putData("/atapi/enterprise/enterprise/autoCopyDeliveryTime", {
      auto_copy_delivery_time: e.detail.value,
      CO_ID: app.globalData.CO_ID,
      CO_NAME: app.globalData.CO_NAME
    }, function (res, error) {
      console.log(res); console.log(error)
      wx.hideLoading();
      if (error) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000
        });
        return false;
      }
      if (res.data.success) {
        app.globalData.auto_copy_delivery_time = e.detail.value
        wx.showModal({
          title: '温馨提示',
          content: '设置自动复制时间成功！',
          showCancel:false,
          success: function (res) {

          }
        })
      } else if (res.data.success == false) {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000,
          mask: true
        });
      }
    });
  },
  autoCopyProject:function(){
    wx.navigateTo({
      url: '/pages/schedule/monitor_warehouse?user=copydelivery&warehouse=' + this.data.auto_copy_project
    })
  },
  switchChange(e) {
    console.log(e)
    var that = this;
    var item = String(e.currentTarget.id), item_value = {};
    item_value[item] = e.detail.value;
    this.setData(item_value);

    if (item == 'monthly_statement_mode'){
      var monthly_statement_mode = 'carrier';
      if (item_value[item] == '1'){
        monthly_statement_mode = 'project';
      }
      util.putData("/atapi/enterprise/enterprise/monthlyStatementMode", {
        monthly_statement_mode: monthly_statement_mode,
        CO_ID: app.globalData.CO_ID
      }, function (res, error) {
        console.log(res); console.log(error)
        wx.hideLoading();
        if (error) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000
          });
          return false;
        }
        if (res.data.success) {
          app.globalData.monthly_statement_mode = monthly_statement_mode
          wx.showModal({
            title: '温馨提示',
            content: '切换账单模式成功！',
            showCancel:false,
            success: function (res) {
              
            }
          })
        } else if (res.data.success == false) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000,
            mask: true
          });
        }
      });
    }
    if (item == 'price_schedule_show') {
      var price_schedule_show = that.data.price_schedule_show?1:0;
      util.putData("/atapi/enterprise/enterprise/priceScheduleShow", {
        price_schedule_show: price_schedule_show,
        CO_ID: app.globalData.CO_ID
      }, function (res, error) {
        console.log(res); console.log(error)
        wx.hideLoading();
        if (error) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000
          });
          return false;
        }
        if (res.data.success) {
          app.globalData.price_schedule_show = price_schedule_show?true:false
          wx.showModal({
            title: '温馨提示',
            content: '设置成功！',
            showCancel:false,
            success: function (res) {

            }
          })
        } else if (res.data.success == false) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000,
            mask: true
          });
        }
      });
    }
    if (item == 'price_driver_show') {
      var price_driver_show = that.data.price_driver_show?1:0;
      util.putData("/atapi/enterprise/enterprise/priceDriverShow", {
        price_driver_show: price_driver_show,
        CO_ID: app.globalData.CO_ID
      }, function (res, error) {
        console.log(res); console.log(error)
        wx.hideLoading();
        if (error) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000
          });
          return false;
        }
        if (res.data.success) {
          app.globalData.price_driver_show = price_driver_show?true:false
          wx.showModal({
            title: '温馨提示',
            content: '设置成功！',
            showCancel:false,
            success: function (res) {

            }
          })
        } else if (res.data.success == false) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000,
            mask: true
          });
        }
      });
    }
    if (item == 'delivery_date_before_today') {
      var delivery_date_before_today = that.data.delivery_date_before_today?1:0;
      util.putData("/atapi/enterprise/enterprise/deliveryDateBeforeToday", {
        delivery_date_before_today: delivery_date_before_today,
        CO_ID: app.globalData.CO_ID
      }, function (res, error) {
        console.log(res); console.log(error)
        wx.hideLoading();
        if (error) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000
          });
          return false;
        }
        if (res.data.success) {
          app.globalData.delivery_date_before_today = delivery_date_before_today?true:false
          wx.showModal({
            title: '温馨提示',
            content: '设置成功！',
            showCancel:false,
            success: function (res) {

            }
          })
        } else if (res.data.success == false) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000,
            mask: true
          });
        }
      });
    }
    if (item == 'day_report_push') {
      var day_report_push = that.data.day_report_push?1:0;
      util.putData("/atapi/enterprise/enterprise/dayReportPush", {
        day_report_push: day_report_push,
        CO_ID: app.globalData.CO_ID
      }, function (res, error) {
        console.log(res); console.log(error)
        wx.hideLoading();
        if (error) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000
          });
          return false;
        }
        if (res.data.success) {
          app.globalData.day_report_push = day_report_push
          wx.showModal({
            title: '温馨提示',
            content: '设置成功！',
            showCancel:false,
            success: function (res) {

            }
          })
        } else if (res.data.success == false) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000,
            mask: true
          });
        }
      });
    }
    if (item == 'income_taxes') {
      var income_taxes = that.data.income_taxes?1:0;
      util.putData("/atapi/enterprise/enterprise/incomeTaxes", {
        income_taxes: income_taxes,
        CO_ID: app.globalData.CO_ID
      }, function (res, error) {
        console.log(res); console.log(error)
        wx.hideLoading();
        if (error) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000
          });
          return false;
        }
        if (res.data.success) {
          app.globalData.income_taxes = income_taxes
          wx.showModal({
            title: '温馨提示',
            content: '设置成功！',
            showCancel:false,
            success: function (res) {

            }
          })
        } else if (res.data.success == false) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000,
            mask: true
          });
        }
      });
    }
    if (item == 'auto_reach') {
      var auto_reach = that.data.auto_reach?1:0;
      util.putData("/atapi/enterprise/enterprise/autoReach", {
        auto_reach: auto_reach,
        CO_ID: app.globalData.CO_ID
      }, function (res, error) {
        console.log(res); console.log(error)
        wx.hideLoading();
        if (error) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000
          });
          return false;
        }
        if (res.data.success) {
          app.globalData.auto_reach = auto_reach
          wx.showModal({
            title: '温馨提示',
            content: '设置成功！',
            showCancel:false,
            success: function (res) {

            }
          })
        } else if (res.data.success == false) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000,
            mask: true
          });
        }
      });
    }
    if (item == 'auto_copy_delivery') {
      var auto_copy_delivery = that.data.auto_copy_delivery?1:0;
      util.putData("/atapi/enterprise/enterprise/autoCopyDelivery", {
        auto_copy_delivery: auto_copy_delivery,
        CO_ID: app.globalData.CO_ID
      }, function (res, error) {
        console.log(res); console.log(error)
        wx.hideLoading();
        if (error) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000
          });
          return false;
        }
        if (res.data.success) {
          app.globalData.auto_copy_delivery = auto_copy_delivery
          wx.showModal({
            title: '温馨提示',
            content: '设置成功！',
            showCancel:false,
            success: function (res) {

            }
          })
        } else if (res.data.success == false) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000,
            mask: true
          });
        }
      });
    }
    if (item == 'auto_copy_delivery_vehicle') {
      var auto_copy_delivery_vehicle = that.data.auto_copy_delivery_vehicle?1:0;
      util.putData("/atapi/enterprise/enterprise/autoCopyDeliveryVehicle", {
        auto_copy_delivery_vehicle: auto_copy_delivery_vehicle,
        CO_ID: app.globalData.CO_ID
      }, function (res, error) {
        console.log(res); console.log(error)
        wx.hideLoading();
        if (error) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000
          });
          return false;
        }
        if (res.data.success) {
          app.globalData.auto_copy_delivery_vehicle = auto_copy_delivery_vehicle
          wx.showModal({
            title: '温馨提示',
            content: '设置成功！',
            showCancel:false,
            success: function (res) {

            }
          })
        } else if (res.data.success == false) {
          wx.showToast({
            title: res.data.data,
            image: '/images/wrong.png',
            duration: 3000,
            mask: true
          });
        }
      });
    }
  },
  registerDriver: function () {
    util.registerDriver(app, this)
  },
  registerCompany: function () {
    util.registerCompany(app, this)
  },
  showModal(e) {
    var that = this;
    this.setData({
      modalName: e.currentTarget.dataset.target
    })
    if(e.currentTarget.dataset.target == 'paymentModeModal'){
      var payment_mode = that.data.payment_mode;
      var _payment_mode = payment_mode.split(",");
      var payment_mode_list = [];
      if(_payment_mode.length > 0){
          for(var i=0;i<_payment_mode.length;i++){
            var _pm = String(_payment_mode[i]).split(":")
            payment_mode_list.push({
               name:_pm[0],
               value:String(_pm[1]).replace('%','')
            })
          }
      }
      that.setData({
         payment_mode_list:payment_mode_list
      })
   }
  },
  hideModal(e) {
    this.setData({
      modalName: null
    })
  },
  addPmItem:function(){
    var that = this;
    var payment_mode_list = that.data.payment_mode_list;
    payment_mode_list.push({name:'',value:''});
    that.setData({
      payment_mode_list:payment_mode_list
    })
  },
  deletePmItem:function(e){
    var that = this;
    var payment_mode_list = that.data.payment_mode_list;
    if(payment_mode_list.length == 1){
      wx.showToast({
        title: "至少一种方式",
        image: '/images/wrong.png',
        duration: 3000
      });
       return false;
    }
    var index = e.currentTarget.dataset.index;
    var _payment_mode_list = [];
    for(var i=0;i<payment_mode_list.length;i++){
      if(i != index){
        _payment_mode_list.push(payment_mode_list[i])
      }
   }
    that.setData({
      payment_mode_list:_payment_mode_list
    })
  },
  pminput:function(e){
    var that = this;
    var type = e.currentTarget.dataset.type;
    var index = e.currentTarget.dataset.index;
    var value = e.detail.value;
    var payment_mode_list = that.data.payment_mode_list;
    for(var i=0;i<payment_mode_list.length;i++){
       if(i == index){
          if(type == 'name'){
            payment_mode_list[i].name = value;
          }
          if(type == 'value'){
            if(isNaN(value) == false){
              payment_mode_list[i].value = value;
            }else{
              wx.showToast({
                title: "请输入数字",
                image: '/images/wrong.png',
                duration: 3000
              });
            }
          }
       }
    }
    that.setData({
      payment_mode_list:payment_mode_list
    })
  },
  //保存付款方式
  savePaymentMode: function (e) {
    var that = this;
    var payment_mode_list = that.data.payment_mode_list;
    var _payment_mode = new Array();
    var isPass = true;
    var percentage = 0;
    for(var i=0;i<payment_mode_list.length;i++){
      percentage += Number(payment_mode_list[i].value);
      if(payment_mode_list[i].name == '' || payment_mode_list[i].value == ''){
        wx.showToast({
          title: "有空的条目",
          image: '/images/wrong.png',
          duration: 3000
        });
        isPass = false;
        return false;
      }
      _payment_mode[i] = payment_mode_list[i].name+':'+payment_mode_list[i].value+'%'
   }
   if(percentage != 100){
      wx.showToast({
        title: "总比率不等100",
        image: '/images/wrong.png',
        duration: 3000
      });
      isPass = false;
      return false;
   }
    that.setData({
      payment_mode:_payment_mode.join(',')
    })
    if(isPass){
      util.putData("/atapi/enterprise/enterprise/savePaymentMode", {
        'payment_mode': that.data.payment_mode,
        'user_id': app.globalData.user_id,
        'CO_ID': app.globalData.CO_ID,
        'CO_NAME': app.globalData.CO_NAME
      }, function (res, error) {
        console.log(res); console.log(error)
        if (res.data.success) {
          app.globalData.payment_mode = that.data.payment_mode
          wx.showModal({
            title: '温馨提示',
            content: '设置成功！',
            success: function (res) {

            }
          })
          that.setData({
            modalName: null
          })
        } else {
          wx.showToast({
            title: "保存失败",
            image: '/images/wrong.png',
            duration: 3000
          });
        }
      });
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    wx.getStorage({
      key: 'monitor_warehouse',
      success: function (res) {
        if (res.data) {
          var data = res.data;
          var auto_copy_project_name = [],auto_copy_project= [];
          for(var i=0;i<data.length;i++){
            auto_copy_project_name.push(data[i].name);
            auto_copy_project.push(data[i].value);
          }
          that.setData({
            auto_copy_project_name: auto_copy_project_name.join(','),
            auto_copy_project: auto_copy_project.join(',')
          });
          util.putData("/atapi/enterprise/enterprise/autoCopyDeliveryProject", {
            auto_copy_project_name: that.data.auto_copy_project_name,
            auto_copy_project: that.data.auto_copy_project,
            CO_ID: app.globalData.CO_ID,
            CO_NAME: app.globalData.CO_NAME
          }, function (res, error) {
            console.log(res); console.log(error)
            wx.hideLoading();
            if (error) {
              wx.showToast({
                title: res.data.data,
                image: '/images/wrong.png',
                duration: 3000
              });
              return false;
            }
            if (res.data.success) {
              app.globalData.auto_copy_project = that.data.auto_copy_project;
              app.globalData.auto_copy_project_name = that.data.auto_copy_project_name;
              wx.showModal({
                title: '温馨提示',
                content: '设置自动复制项目成功！',
                showCancel:false,
                success: function (res) {
      
                }
              })
            } else if (res.data.success == false) {
              wx.showToast({
                title: res.data.data,
                image: '/images/wrong.png',
                duration: 3000,
                mask: true
              });
            }
          });
        }
      },
      complete: function (res) {
        wx.removeStorage({
          key: 'monitor_warehouse',
          success: function (res) {}
        });
      }
    });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})